# To change this template, choose Tools | Templates
# and open the template in the editor.

class Cluster
  attr_accessor :centroide,:elementi,:energia,:centroid_vector
  def initialize(centroide, centroid_vector)
    @centroide= centroide
    @elementi= []
    @energia= 0.0
    @centroid_vector= centroid_vector
  end
  def add_element(e)
    self.elementi.push(e)
    self.update_energy(e)
  end
  def update_energy(e)
    self.energia= self.energia + self.centroid_vector[e]
  end
  def used(e)
    return (self.elementi.include?(e) || (e==self.centroide))
  end
  def energia
    @energia
  end
    def centroide
    @centroide
  end
      def elementi
    @elementi
  end
end
